package heima3_2.cn.osc.presenter;

import java.util.List;

import heima3_2.cn.osc.model.bean.BlogBean;
import heima3_2.cn.osc.model.bean.GeneralBlogBean;
import heima3_2.cn.osc.ui.main_fragment.SyntheFragment;
import retrofit2.Call;
import retrofit2.Response;

/**
 * Created by Administrator on 2017/1/15 0015.
 */

public class SyntheRecommendPresenter extends BasePresenter<GeneralBlogBean> {
    private  SyntheFragment syntherMainFragment;
    public SyntheRecommendPresenter(SyntheFragment syntherMainFragment){
        this.syntherMainFragment=syntherMainFragment;
    }
    @Override
    protected void getFailureData(Throwable t) {
        t.printStackTrace();
    }

    @Override
    protected void getSuccessData(Response<GeneralBlogBean> response) {
        GeneralBlogBean body = response.body();
        List<BlogBean> blogs = body.getBlogs();
        syntherMainFragment.mRecommendAdapter.setDatas(blogs);
    }

    @Override
    public void getData(int pager) {

        Call<GeneralBlogBean> latest = mRetrofitInterface.getDetailInfo(0, 20, "recommend");
        latest.enqueue(mCallback);
    }
}
